package com.b2c.product.controller.platform;

import com.b2c.product.pojo.entity.Branch;
import com.b2c.product.service.BranchService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import content.enumeration.BranchStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.Result;

@RestController("platformBranchController")
@RequestMapping("/platform/branch")
public class BranchController {
    @Autowired
    BranchService branchService;

    /**
     * 通过商家id查询
     *
     * @param adminId
     * @return
     */
    @GetMapping("/query/{adminId}")
    public Result queryByAdminId(@PathVariable("adminId") Integer adminId) {
        return branchService.getBranchByAdminId(adminId);
    }

    /**
     * 分页查询所有品牌
     *
     * @param page
     * @return
     */
    @GetMapping("/query/all")
    public Result queryAllBranch(IPage<Branch> page) {
        return branchService.queryAllBranch(page);
    }

    /**
     * 修改品牌状态
     */
    @PostMapping("/update/{status}")
    public Result updateBranch(@PathVariable BranchStatus status,Integer adminId) {
        return branchService.updateStatus(status,adminId);
    }
}
